package org.sucri.floxs.ext.form;

import org.sucri.floxs.ext.Label;
import org.sucri.floxs.ext.JsFunction;
import org.sucri.floxs.ext.widget.ExtWidget;
import org.sucri.floxs.utils.Json_Util;
import org.sucri.floxs.Tools;

/**
 * Created by IntelliJ IDEA.
 * User: Wen Yu
 * Date: Aug 19, 2007
 * Time: 4:44:55 PM
 * To change this template use File | Settings | File Templates.
 */
abstract public class FormField extends ExtWidget implements JsFunction
{
  private static final String LABEL  = "fieldLabel";
  private static final String NAME   = "name";
  private static final String WIDTH  = "width";
  
  public FormField(String label, String name, int w)
  {
    if (Tools.good(label)) mConfig.put(LABEL, label);
    setName(name);
    if (w > 0)             mConfig.put(WIDTH, w);
  }
  public void setName(String s)
  {
    if (Tools.good(s))
    {
      s.replaceAll("\\ ", "_");
      mConfig.put(NAME,  s);
    }
  }
}
